]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
allView, folderView: Only add icons once
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 30 Jul 2019 15:15:51 +0000 (12:15 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 6 Aug 2019 00:20:31 +0000 (21:20 -0300)
FolderView and AllView currently check if the item is
present in the BaseAppView._items map, in order to avoid
adding the same icon multiple times.

Now that BaseAppView._loadApps() has a different role --
it returns a list with all app icons, and BaseAppView
diffs with the current list of app icons -- checking the
BaseAppView._items map is wrong.

Make sure there are no duplicated items in the temporary
array returned by all _loadApps() implementations. Remove
the now unused BaseAppView.hasItem() method.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/645

js/ui/appDisplay.js

index 5264a35cbad03a005461f3660d60226ca501a7a0..d74630b98c679f40f13a2250a8fdd995bf410d0a 100644 (file)
@@ -149,15 +149,8 @@ class BaseAppView {
         return this._allItems;
     }
 
-    hasItem(id) {
-        return this._items[id] !== undefined;
-    }
-
     addItem(icon) {
         let id = icon.id;
-        if (this.hasItem(id))
-            throw new Error(`icon with id ${id} already added to view`);
-
         this._allItems.push(icon);
         this._items[id] = icon;
     }
@@ -394,12 +387,13 @@ var AllView = class AllView extends BaseAppView {
 
         let folders = this._folderSettings.get_strv('folder-children');
         folders.forEach(id => {
-            if (this.hasItem(id))
-                return;
             let path = this._folderSettings.path + 'folders/' + id + '/';
-            let icon = new FolderIcon(id, path, this);
-            icon.connect('name-changed', this._itemNameChanged.bind(this));
-            icon.connect('apps-changed', this._refilterApps.bind(this));
+            let icon = this._items[id];
+            if (!icon) {
+                icon = new FolderIcon(id, path, this);
+                icon.connect('name-changed', this._itemNameChanged.bind(this));
+                icon.connect('apps-changed', this._refilterApps.bind(this));
+            }
             newApps.push(icon);
             this.folderIcons.push(icon);
         });
@@ -1147,9 +1141,6 @@ var FolderView = class FolderView extends BaseAppView {
         let excludedApps = this._folder.get_strv('excluded-apps');
         let appSys = Shell.AppSystem.get_default();
         let addAppId = appId => {
-            if (this.hasItem(appId))
-                 return;
-
             if (excludedApps.includes(appId))
                 return;
 
@@ -1160,6 +1151,9 @@ var FolderView = class FolderView extends BaseAppView {
             if (!app.get_app_info().should_show())
                 return;
 
+            if (apps.some(appIcon => appIcon.id == appId))
+                return;
+
             let icon = new AppIcon(app);
             apps.push(icon);
         };